﻿using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using SqlSugar;
using System.Web.Http;
using wnet.admin.dbhelper;
using wnet.admin.Models;
using System;
using Models;
using wnet.admin.Models.dto;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;


namespace wnet.admin.Controllers.ywBusiness
{
    [System.Web.Http.Route("ywbusiness/ywTest/{action}")]
    public class ywTestController : ApiController
    {
        // GET: ywTest
        /// <summary>
        /// chart 线集合
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [HttpGet]
        public void Test()
        {
            byte[] revByte = ReadData();
            ConstDefine.mSensorBusiness.AddProcessObj(revByte);
            ConstDefine.mSensorAlarmBusiness.AddProcessObj(revByte);
        }

        public byte[] ReadData()
        {
            string physicalPath = System.Web.Hosting.HostingEnvironment.MapPath("~/");
            byte[] contents = System.IO.File.ReadAllBytes($"{physicalPath}/DataBase/Data.dat");
            return contents;
        }


        private List<List<Point>> DealData(object obj)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(stream, obj);
                stream.Seek(0, SeekOrigin.Begin);

                //反序列化
                List<List<Point>> res = (List<List<Point>>)bf.Deserialize(stream);

                return res;
            }
        }

        public class DataModel
        {
            public string[] categories { get; set; }
            public int[][] seriesData { get; set; }

            public int[] Locations { get; set; }
        }
    }
}